<!--
/**************************************************
* @ balanceinforecord.jsp
*
* Copyright   2006 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/04/17, Jenny Li
*  1) first release
*  v1.01, 2006/06/21, Jenny Li
*  1) 修改取得手动设定参数类型日期区间显示处理方式
/**************************************************
-->
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="../../common.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<title>对帐调整</title>
	<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<LINK href="<%=root%>/css/caigouxitong.css"" type=text/css rel=stylesheet>		
	<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
	<SCRIPT language="JavaScript" src="<%=root%>/js/calendar.js"></SCRIPT>
	<SCRIPT language="JavaScript" src="<%=root%>/js/hi-check.js"></SCRIPT>
	<%
		GSBalanceParamBean tBalParmBean = (GSBalanceParamBean)request.getAttribute("balanceparm");
		HashMap tMap = (HashMap)request.getAttribute("orderdept");
		ArrayList tOrderDeptList = (ArrayList)tMap.get("organization");
		String tStrDate = (String)request.getAttribute("balancestrdate");
		String tEndDate = (String)request.getAttribute("balanceenddate");
		
	%>
	<script>

		var counter;
		function process(){
			var d = new Date();
			var curYear = d.getYear();
			var curMonth = d.getMonth();
			
			// modify by daniel 
			/*if(parseInt(document.all.balanceYear.value) > curYear){
				alert("年份不能大于系统年！");
				return false;
			}
			if(parseInt(document.all.balanceMonth.value) > (curMonth + 1)){
				alert("月份不能大于系统月！");
				return false;				
			}*/
			// modify by daniel
			// add by daniel
			// 时间在当前年时, 所选月份不能小于当前月
			if(parseInt(document.all.balanceYear.value)==curYear){		
			  if(parseInt(document.all.balanceMonth.value) < (curMonth + 1)){
				alert("不能选当前时间之前的月份！");
				return false;
			  }
			}
			// add by daniel
			
			
			if(!confirm("是否确定将所选订单纳入"+document.all.balanceYear.value+"年"+document.all.balanceMonth.value+"月结算?")){
				return false;
			}
			
			opener.document.pager.balanceYear.value=document.all.balanceYear.value;
			opener.document.pager.balanceMonth.value=document.all.balanceMonth.value;
			opener.document.pager.balanceStrDate.value=document.all.balanceStrDate.value;
			opener.document.pager.balanceEndDate.value=document.all.balanceEndDate.value;
			opener.location="javascript:dosubmit()";
			window.close();

		}
		
		function changeDate(obj1 , obj2)
		{
			var year1 = obj1.value;
			var year2 = obj1.value;
			var month1;
			var strDate = "<%=tBalParmBean.getGs_balance_start_date()%>";
			var endDate = "<%=tBalParmBean.getGs_balance_end_date()%>";

			<%
				if(tBalParmBean.getGs_balance_date_type().equals(GSBaseConstants.NATURE_BALANCE_DATE)){
			%>
					for(i=1; i<=12; i++){
						if(obj2.value == i){					
				    		endDate = getMaxDay(parseInt(year1),parseInt(obj2.value));
				    		break;
				    	}

					}
				    month1 = obj2.value;
			<%	
				}else if(tBalParmBean.getGs_balance_date_type().equals(GSBaseConstants.MANUAL_BALANCE_DATE)){
			%>
				    //month1= obj2.value;
					if(parseInt(strDate) > parseInt(endDate) || parseInt(strDate) == parseInt(endDate)){
							if (obj2.value == "1")
							{
								month1 = "12";
								year1 = parseInt(year1) - 1;
							}else{						
								month1 = parseInt(obj2.value) - 1;
							}
					}else{
						month1 = obj2.value;
					}
			<%	    
				}
			%>
			 
			var month2 = obj2.value;

			if (parseInt(month1) < 10 ){
				month1 = "0" + month1;			
			}
			if(parseInt(month2) < 10)
			{
				month2 = "0" + month2;
			}			
			if(parseInt(strDate) < 10){
				strDate = "0" + strDate;
			}
			if(parseInt(endDate) < 10){		
				endDate = "0" + endDate;
			}			
			document.all["balanceStrDate"].value = year1 + "/" + month1 + "/" + strDate;
			document.all["balanceEndDate"].value = year2 + "/" + month2 + "/" + endDate;
		}
		</script>
	</head>
	<body BGCOLOR="#f2f2f2" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
		<form name="orderbalanceform" method="post">
			<p><br>
			</p>
			<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
				<tr>
					<td class="bg_line" height="2"></td>
				</tr>
			</table>
			<br>
			<table class="bg_table" id="Table1" cellspacing="1" cellpadding="0" style="PADDING-RIGHT:5px; PADDING-LEFT:5px"
				width="98%" align="center" border="0">
				<TR height="20">

					<TD class="bg_column" align="center" width=15%>月份</TD>
					<TD class="bg_row_odd" width=35%>
						
						<SELECT ID="Select2" NAME="balanceYear" onchange="changeDate(this,document.all['Select3']);">

						<%
							int length = 15;
							Calendar cal = Calendar.getInstance();
							int curYear = cal.get(Calendar.YEAR);
							
							//modify by daniel
						      for(int i=0; i<length; i++){
							  if(curYear == (2006 + i)){
						%>
							<OPTION value="<%=2006+i%>" selected><%=2006+i%></OPTION>				
						<%	        
							  }else{
						%>
							<OPTION value="<%=2006+i%>"><%=2006+i%></OPTION>			
						<%		    
							    }
							}
						%>						
						</SELECT>年
						<SELECT ID="Select3" NAME="balanceMonth" onchange="changeDate(document.all['Select2'],this);">
						<%
							int curMonth = cal.get(Calendar.MONTH);
							for(int i=1; i<=12; i++){
							    if(curMonth + 1 == i){
						%>
							<OPTION value="<%=i%>" selected><%=i%></OPTION>						
						<%
							    }else{
						%>		
							<OPTION value="<%=i%>"><%=i%></OPTION>												
						<%		    
							    }
							}
						%>
						</SELECT>月
					</TD>
				</TR>

					<div align="center" class="txt_content" style='display:none'> 
						日期
					</div>
					<div align="center" class="txt_content" style='display:none'> 
						<input id="Text27" name='balanceStrDate' readonly onfocus='setday(this)' value='<%=tStrDate%>'> ～ <input id="Text4" name='balanceEndDate' readonly onfocus='setday(this)' value="<%=tEndDate%>">
					</div>


			</table>
		</form>
		<p align="center">
			<INPUT type="button" class="kuang" value="确定" NAME="Button1" onClick="process()">
			<INPUT type="button" class="kuang" value="取消" NAME="Button2" onClick="window.close();">
		</p>
	</body>
</html>
